home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / totsrc11.zip / TOTFAST.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  15KB  |  354 lines

  1. ;                  Copyright 1991 TechnoJock Software, Inc. 
  2. ;                             All Rights Reserved           
  3. ;                            Restricted by License          
  4.  
  5. ;                                 FastTOP.ASM 
  6.  
  7. ;                               Version Alpha 2
  8.  
  9. %Title "TOT Toolkit screen writing and memory moving routines"
  10.  
  11. ;       IDEAL
  12.  
  13. SEGMENT DATA byte public
  14.  
  15.         EXTRN   SnowProne : BYTE
  16.  
  17. ENDS DATA
  18.  
  19.  
  20. SEGMENT CODE byte public
  21.  
  22.         ASSUME  CS:CODE, DS:DATA
  23.  
  24.         PUBLIC  AsmWrite, AsmPWrite, AsmAttr
  25.         PUBLIC  ASMMoveFromScreen, ASMMoveToScreen
  26.  
  27. ;  |||||||||||||||||||||||||||||||
  28. ;  |     A d j u s t E S D I     |
  29. ;  |||||||||||||||||||||||||||||||
  30.  
  31. ;   Local routine that computes the offset from the top left of
  32. ;   the screen. You must set ES:DI to point to start of screen 
  33. ;   before calling.
  34.  
  35. AdjustESDI      PROC NEAR
  36.  
  37.         XOR     DX,DX                   ;set DX to 0
  38.         MOV     CL,DL                   ;CL = 0
  39.         MOV     BH,DL                   ;BH = 0
  40.         MOV     AH,DL                   ;AH = 0
  41.         DEC     CH                      ;set CH to number of full rows
  42.         MUL     CH                      ;AX <- CH * AL  i.e. rows * width
  43.         SHL     AX,1                    ;*2 for char and attr
  44.         ADD     DI,AX                   ;add rows*width*2 to DI 
  45.         DEC     BX                      ;decrease cols by 1
  46.         SHL     BX,1                    ;multiply cols by 2
  47.         ADD     DI,BX                   ;add cols to DI
  48.         XOR     AX,AX                   ;set AX to zero
  49.         RET                             ;Return
  50.  
  51. AdjustESDI      ENDP
  52.  
  53. ;||||||||||||||||||||||||||||
  54. ;|     A S M w r i t e      |
  55. ;||||||||||||||||||||||||||||
  56.  
  57. ;  Turbo passed parameters
  58.  
  59. AWSt            EQU     DWORD PTR [BP+6]
  60. AWAttr          EQU     BYTE PTR [BP+10]
  61. AWRow           EQU     BYTE PTR [BP+12]
  62. AWCol           EQU     BYTE PTR [BP+14]
  63. AWWidth         EQU     BYTE PTR [BP+16]
  64. AWScreenStart   EQU     DWORD PTR [BP+18]
  65.  
  66. AsmWrite       PROC FAR
  67.  
  68.         PUSH    BP                      ;Save BP
  69.         MOV     BP,SP                   ;Set up stack frame
  70.         PUSH    DS                      ;Save DS
  71.         MOV     CH,AWRow                ;CH = Row
  72.         MOV     BL,AWCol                ;BL = Column
  73.         MOV     AL,AWWidth              ;AL = screen width
  74.         LES     DI,AWScreenStart        ;Set up ES:DI to start of screen
  75.         CALL    AdjustESDI              ;move ES:DI to X,Y coord for write
  76.         MOV     CL,SnowProne            ;Need to wait?
  77.         LDS     SI,AWSt                 ;DS:SI points to St[0]
  78.         CLD                             ;Set SI inc. direction to forward
  79.         LODSB                           ;AX = Length(St); DS:SI -> St[1]
  80.         XCHG    AX,CX                   ;CX = Length; AL = WaitForRetrace
  81.         JCXZ    AWExit                  ;exit if CX = 0, i.e. string empty
  82.         MOV     AH,AWAttr               ;AH = display attribute
  83.         RCR     AL,1                    ;If WaitForRetrace is False...
  84.         JNC     AWMono                  ; use "AWMono" routine
  85.         MOV     DX,03DAh                ;Point DX to CGA status port
  86. AWGetNext:
  87.         LODSB                           ;Load next character into AL
  88.         MOV     BX,AX                   ;Store video word in BX
  89.         CLI                             ;hold interrupts
  90. AWWaitNoH:
  91.         IN      AL,DX                   ;get retrace situation
  92.         TEST    AL,8                    ;retracing?
  93.         JNZ     AWStore                 ;If so, go
  94.         RCR     AL,1                    ;Else, wait for end of
  95.         JC      AWWaitNoH               ; horizontal retrace
  96. AWWaitH:
  97.         IN      AL,DX                   ;get retrace situation
  98.         RCR     AL,1                    ;Wait for horizontal
  99.         JNC     AWWaitH                 ; retrace
  100. AWStore:
  101.         MOV     AX,BX                   ;Move word back to AX...
  102.         STOSW                           ; and then to screen
  103.         STI                             ;OK to interrupt now
  104.         LOOP    AWGetNext               ;Get next character
  105.         JMP     AWExit                  ;wind up
  106. AWMono:
  107.         LODSB                           ;Load next character into AL
  108.         STOSW                           ;Move video word into place
  109.         LOOP    AWMono                  ;Get next character
  110. AWExit:
  111.         POP     DS                      ;clean up and go home
  112.         MOV     SP,BP                   ;
  113.         POP     BP                      ;
  114.         RET     16                      ;16 bytes for passed paremeters 
  115.                                         ;(minimum is 2 bytes per param)
  116.  
  117. AsmWrite       ENDP
  118.  
  119. ;||||||||||||||||||||||||||||||
  120. ;|     A S M P w r i t e      |
  121. ;||||||||||||||||||||||||||||||
  122.  
  123. ;  Turbo passed parameters
  124.  
  125. PWSt            EQU     DWORD PTR [BP+6]
  126. PWRow           EQU     BYTE PTR [BP+10]
  127. PWCol           EQU     BYTE PTR [BP+12]
  128. PWWidth         EQU     BYTE PTR [BP+14]
  129. PWScreenStart   EQU     DWORD PTR [BP+16]
  130.  
  131. AsmPWrite      PROC FAR
  132.  
  133.         PUSH    BP                      ;Save BP
  134.         MOV     BP,SP                   ;Set up stack frame
  135.         PUSH    DS                      ;Save DS
  136.         MOV     CH,PWRow                ;CH = Row
  137.         MOV     BL,PWCol                ;BL = Column
  138.         MOV     AL,PWWidth              ;AL = screen width
  139.         LES     DI,PWScreenStart        ;Set up ES:DI to start of screen
  140.         CALL    AdjustESDI              ;move ES:DI to X,Y coord for write
  141.         MOV     CL,Snowprone            ;Need to wait?               
  142.         LDS     SI,PWSt                 ;DS:SI points to St[0]
  143.         CLD                             ;Set direction to forward
  144.         LODSB                           ;AX = Length(St); DS:SI -> St[1]
  145.         XCHG    AX,CX                   ;CX = Length; AL = Wait
  146.         JCXZ    PWExit                  ;exit if string empty
  147.         RCR     AL,1                    ;If WaitForRetrace is False...
  148.         JNC     PWNoWait                ; use PWNoWait routine
  149.         MOV     DX,03DAh                ;Point DX to CGA status port
  150. PWGetNext:
  151.         LODSB                           ;Load next character into AL
  152.         MOV     AH,AL                   ;Store char in AH
  153.         CLI                             ;hold interrupts
  154. PWWaitNoH:
  155.         IN      AL,DX                   ; get retrace situation
  156.         TEST    AL,8                    ;Check for vertical retrace
  157.         JNZ     PWStore                 ; In progress? go
  158.         RCR     AL,1                    ;Else, wait for end of
  159.         JC      PWWaitNoH               ; horizontal retrace
  160. PWWaitH:
  161.         IN      AL,DX                   ;Get 6845 status again
  162.         RCR     AL,1                    ;Wait for horizontal
  163.         JNC     PWWaitH                 ; retrace
  164. PWStore:
  165.         MOV     AL,AH                   ;Move char back to AL...
  166.         STOSB                           ; and then to screen
  167.         STI                             ;OK to interrupt now
  168.         INC     DI                      ;Skip attribute bytes
  169.         LOOP    PWGetNext               ;Get next character
  170.         JMP     PWExit                  ;Done
  171. PWNoWait:
  172.         MOVSB                           ;Move character to screen
  173.         INC     DI                      ;Skip attribute bytes
  174.         LOOP    PWNoWait                ;Get next character
  175. PWExit:
  176.         POP     DS                      ;Clean up and go home
  177.         MOV     SP,BP                   ;
  178.         POP     BP                      ;
  179.         RET     14                      ;
  180.  
  181. AsmPWrite      ENDP
  182.  
  183. ;||||||||||||||||||||||||||
  184. ;|     A S M a t t r      |
  185. ;||||||||||||||||||||||||||
  186.  
  187. ;  Turbo passed parameters
  188.  
  189. ANumber        EQU     WORD PTR [BP+6]
  190. AAttr          EQU     BYTE PTR [BP+8]
  191. ARow           EQU     BYTE PTR [BP+10]
  192. ACol           EQU     BYTE PTR [BP+12]
  193. PWWidth        EQU     BYTE PTR [BP+14]
  194. PWScreenStart  EQU     DWORD PTR [BP+16]
  195.  
  196.  
  197. ASMattr PROC FAR
  198.  
  199.         PUSH